// 始于2023.10.9 沈忠锐
// 从车任务相关函数

#ifndef _AGVTASK_h
#define _AGVTASK_h
#include <DCMotor.h>

#if defined(ARDUINO) && ARDUINO >= 100
	#include "Arduino.h"
#else
	#include "WProgram.h"
#endif

extern uint8_t Go_Speed;     // 全局行进速度值
extern uint8_t wheel_Speed;  // 全局转弯速度值
extern uint16_t Go_Temp;    // 全局前进码盘值
typedef struct 
{
char Cd_X;
char Cd_Y;
int k;
int vernier;
} Statick[50];

static int linked_list = 0;
Statick link;
static uint8_t tracking=1; //循迹标志位，为一正常循迹，置0不循迹（在任务里完成循迹）
static uint8_t Infrared_data[6];//红外数据储存
static uint8_t Zigbee_data[8];//zigbee数据储存
static uint8_t Usart_buffer[8];//串口缓冲
class _TASK
{
public:
	_TASK();
	~_TASK();
    void OpenMV_Track(uint8_t Car_Speed);//视频循迹
	void AGV_Path_Analysis();//循迹板循迹完成任务路径
    void AGV_Path_Analysis_Video();//视频循迹完成任务路径
	uint8_t Quick_reading_FS(uint8_t linked_list);
	void Change_dir(int dir_b, int dir_a);
	void Initialization(void);
    void To_Car(uint8_t data, uint8_t data0, uint8_t data1, uint8_t data2);
    void Current_Task(uint8_t Task_ID);	
    void delay_s(uint8_t s);
    void Send_Data_Using_Zigbee(uint8_t head, uint8_t primary, uint8_t data0, uint8_t data1,uint8_t data2);//发送8位Zigbee数据
    void Send_Data_Using_Zigbee(uint8_t*data);
    void Send_Data_Using_Infrared(uint8_t head, uint8_t primary, uint8_t data0, uint8_t data1,uint8_t data2,uint8_t data3);//发送6位红外数据
    void Send_Data_Using_Infrared(uint8_t*data);
    void Read_Data_K210(uint8_t*data,uint8_t len);
    void Traffic_light_recognition();//交通灯识别
    void QR_code_recognition(void);//二维码识别
    void Ultrasonic_Ranging();//超声波测距
    void Send_Voice_Data(uint8_t*data);//语音播报gb2312指定文本

    /*开启巡线*/
    uint8_t K210_trackdi_open[8] = {0x55, 0x02, 0x91, 0x01, 0x00, 0x00, 0x92, 0xBB};
    /*关闭巡线*/
    uint8_t K210_trackdi_close[8] = {0x55, 0x02, 0x91, 0x02, 0x00, 0x00, 0x93, 0xBB};
    
    const uint8_t Voice_1[3]={0xD2,0xBB};//语音播报1
    uint8_t Voice_2[3]={0xB6,0xFE};
    uint8_t Voice_3[3]={0xC8,0xFD };
    uint8_t Voice_4[3]={0xCB,0xC4 };
    uint8_t Voice_5[3]={0xCE,0xE5 };
    uint8_t Voice_6[3]={0xC1,0xF9 };
    uint8_t Voice_7[3]={0xC6,0xDF };
    
    uint8_t Voice_DZ[5]={ 0xB5,0xC0,0xD5,0xA2};//语音播报道闸
    uint8_t Voice_DaoChe[9]={0xB5,0xB9,0xB3,0xB5,0xC8,0xEB,0xBF,0xE2 };
    uint8_t Voice_CeJu[5]={ 0xB2,0xE2,0xBE,0xE0};
    uint8_t Voice_Jtd[7]={0xBD,0xBB,0xCD,0xA8,0xB5,0xC6 };
    uint8_t Voice_Finish[13]={0xB4,0xD3,0xB3,0xB5,0xC8,0xCE,0xCE,0xF1,0xCD,0xEA,0xB3,0xC9};
    uint8_t Voice_QR_Open[15]={0xBF,0xAA,0xCA,0xBC,0xB6,0xFE,0xCE,0xAC,0xC2,0xEB,0xCA,0xB6,0xB1,0xF0};
    uint8_t Voice_Open[9]={0xBF,0xAA,0xCA,0xBC,0xCA,0xB6,0xB1,0xF0};
    uint8_t Voice_red[3]={0xBA,0xEC};
    uint8_t Voice_grepp[3]={0xC2,0xCC};
    uint8_t Voice_yellow[3]={ 0xBB,0xC6};
    uint8_t Voice_QR_Close[17]={0x08,0xF6,0x12,0x04,0x0D,0x93,0x11,0xDE,0x07,0x95,0x10,0x7E,0x06,0xF4,0x0D,0x0A};
    uint8_t Voice_Traffic_Close[17]={0x0A,0x74,0x0D,0x74,0x08,0x5A,0x11,0xDE,0x07,0x95,0x10,0x7E,0x06,0xF4,0x0D,0x0A};

   
private:
};


#endif

